package com.lwj.conteroller;

import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.demo.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;

/**
 * Created by Administrator on 2021/2/24.
 */
@RestController
@RequestMapping("lwj")
public class conteroller {

    @Reference
    private DemoService demoService;

    @GetMapping("/demo1")
    public  String getDemo(){
        return  "hello";
    }

    @GetMapping("/demo2")
    public  String getDemo2(){
        Random random = new Random();
        for(int i = 0;i<100;i++){
            int xReg = random.nextInt(2)+1;
            System.setProperty("clientRegion",String.valueOf(xReg));
            System.out.println("request: "+xReg );
            System.out.println("result: " + demoService.sayHello("zsy"));
        }
        return  "hello 2";
    }
}
